const {Controller} = require("ee-core");
const Services = require("ee-core/services");
const {json} = require("../utils");

class WallpaperController extends Controller {
    wallpaper = Services.get('wallpaper')

    constructor(ctx) {
        super(ctx);
    }

    async downloadToDir(args) {
        try {
            await this.wallpaper.downloadToDir(args)
            return json({})
        } catch (e) {
            return json({code: 500, msg: e.message})
        }

    }

    async setWallpaper(args) {
        try {
            await this.wallpaper.setWallpaper(args)
            return json({})
        } catch (e) {
            return json({code: 500, msg: e.message})
        }

    }

    async getPageData(args) {
        try {
            return await this.wallpaper.getPageData(args)
        } catch (e) {
            return json({code: 500, msg: e.message})
        }
    }
}

WallpaperController.toString = () => '[class WallpaperController]';
module.exports = WallpaperController;